<!--
 * @Author: 花香蝶自来 1026583651@qq.com
 * @Date: 2024-07-12 09:59:38
 * @LastEditors: 花香蝶自来 1026583651@qq.com
 * @LastEditTime: 2024-07-14 21:28:54
 * @FilePath: /driver/components/tabbar/tabbar.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
	<view>
		<u-tabbar :value="value" @change="change" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true">
			<u-tabbar-item v-for="item in list" :text="item.text" :icon="item.icon"></u-tabbar-item>
			<!-- <u-tabbar-item text="客户池" icon="photo"></u-tabbar-item>
      <u-tabbar-item text="我的" icon="account"></u-tabbar-item> -->
		</u-tabbar>
	</view>
</template>


<script>
	export default {
		name: "tabbar",
		data() {
			return {
				value: "0",
				imgs1: ['8f5cdfb31ea944a79c2dcd2fb954463e.png', "909196d585b544cfb5398d808085663c.png",
					"70c36ba3294847d2b1db3b7e85e7271c.png", "254ae0959ac04397a688373c4d238886.png"
				],
				imgs2: ["846aceefcfe5487baa8150b5a8ffbda7.png", "ab1e70eda0c8414691aab1f49dd522d7.png",
					"f48994b9594b4460a4680bdf9b861e4f.png", "de2511e470f94cb39bc29fe0fa968419.png"
				]
			};
		},
		computed: {

			list() {
				let v = this.value;
				let r = [{
						text: "首页",
						page: "/pagesall/index/index"
					},
					// {
					// 	text: "货源大厅",
					// 	page: "/pagesall/hall/hall"
					// }, 

					{
						text: "运货单",
						page: "/pagesall/order/order"
					},
					{
						text: "我的",
						page: "/pagesall/home/home"
					}
				].map((e, i) => {
					let img = this.imgs1[i]
					if (v == i) {
						img = this.imgs2[i]
					}
					return {
						...e,
						icon: this.$z.imgsrc(img)
					}
				})
				return r;
			},

		},

		module() {

		},
		mounted() {
			this.init()

		},
		// ready
		methods: {
			init() {
				let pages = getCurrentPages();
				console.log(pages);
				let fullPath = pages[pages.length - 1].$page.fullPath
				let i = this.list.findIndex(e => {
					return  fullPath.includes(e.page)
				})
				this.value = String(i)
			},
			change(item) {
				// this.value = item
				let dqitem = this.list[item]
				uni.reLaunch({
					url: dqitem.page
				})
				console.log(item, this.value);
			}
		}
	}
</script>

<style></style>